]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
environment: Split out the prepare and cleanup animation code
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 5 Dec 2025 22:39:23 +0000 (23:39 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 14 Jan 2026 18:09:11 +0000 (19:09 +0100)
We do the same twice, and it's not trivial code anymore, so let's
separate this into another function which returns the prepare and cleanup
functions

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3992>
(cherry picked from commit 7aacc1cab033fd77370b8d03b037892b3dd28a7f)

js/ui/environment.js

index b971ed8aeaf3262caeadea9bde13c0b4644e5fa1..1bd76374b7f723284c155599ce89cc501337ce2a 100644 (file)
@@ -71,6 +71,19 @@ function _makeEaseCallback(params, cleanup) {
     };
 }
 
+function _makeEasePrepareAndCleanup() {
+    const prepare = () => {
+        global.compositor.disable_unredirect();
+        global.begin_work();
+    };
+    const cleanup = () => {
+        global.compositor.enable_unredirect();
+        global.end_work();
+    };
+
+    return {prepare, cleanup};
+}
+
 function _getPropertyTarget(actor, propName) {
     if (!propName.startsWith('@'))
         return [actor, propName];
@@ -128,15 +141,8 @@ function _easeActor(actor, params) {
         actor.set_easing_mode(params.mode);
     delete params.mode;
 
-    const prepare = () => {
-        global.compositor.disable_unredirect();
-        global.begin_work();
-    };
-    const cleanup = () => {
-        global.compositor.enable_unredirect();
-        global.end_work();
-    };
-    let callback = _makeEaseCallback(params, cleanup);
+    const {prepare, cleanup} = _makeEasePrepareAndCleanup();
+    const callback = _makeEaseCallback(params, cleanup);
 
     // cancel overwritten transitions
     let animatedProps = Object.keys(params).map(p => p.replace('_', '-', 'g'));
@@ -209,15 +215,8 @@ function _easeAnimatableProperty(animatable, propName, target, params) {
     if (!actor?.mapped)
         duration = 0;
 
-    const prepare = () => {
-        global.compositor.disable_unredirect();
-        global.begin_work();
-    };
-    const cleanup = () => {
-        global.compositor.enable_unredirect();
-        global.end_work();
-    };
-    let callback = _makeEaseCallback(params, cleanup);
+    const {prepare, cleanup} = _makeEasePrepareAndCleanup();
+    const callback = _makeEaseCallback(params, cleanup);
 
     // cancel overwritten transition
     animatable.remove_transition(propName);